﻿using System;
using LightPersist.Storage;

namespace LightPersist
{
	public static class LightPersistFactory
	{
		public static LightPersistContext Open<TStorage, TMetainfo>(string connectionString) where TStorage:IStorage where TMetainfo : IDomainMetainfoProvider
		{
			var storage = Activator.CreateInstance<TStorage>();
			storage.Connect(connectionString);

			var meta = Activator.CreateInstance<TMetainfo>();

			return new LightPersistContext(storage, meta.Meta);
		}
	}
}